local skel = fk.CreateSkill {
  name = "#lb_zero__mengyao_audio",
}

skel:addEffect(fk.SkillEffect, {
  global = true,
  can_refresh = function(self, event, target, player, data)
    if player == target then
      local all_skills = {
        { "lb_zero__mengyao_leizhu",   "lb_zero__mengyao_tierfeng",           "lb_zero__mengyao_apeika",       "lb_zero__mengyao_satier",        "lb_zero__mengyao_mandela", "lb_zero__mengyao_eling", "lb_zero__mengyao_youhun" },
        { "lb_zero__mengyao_hati",     "lb_zero__mengyao_tanatuosi",          "lb_zero__mengyao_dulahan",      "lb_zero__mengyao_bannileike",    "lb_zero__mengyao_yurenxie" },
        { "lb_zero__mengyao_tepeishi", "lb_zero__mengyao_high_zhuangjiahati", "lb_zero__mengyao_high_dulahan", "lb_zero__mengyao_high_tanatuosi" }
      }
      for i, skill_list in ipairs(all_skills) do
        for _, skill in ipairs(skill_list) do
          if skill == data.skill.name then
            event:setCostData(self, { mengyao_audio_index = i * 2 })
            return true
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local num = (math.random() > 0.5 and -1 or 0) + event:getCostData(self).mengyao_audio_index
    player.room:broadcastPlaySound("./packages/lb_kill_zero/audio/skill/mengyao_audio/yihai_" .. num)
  end,
})

return skel
